require(SCRIPTS_DIR .. ".init");
local BaseScene = require(SCRIPTS_DIR .. ".scenes.BaseScene");
local MainScene = class("MainScene",BaseScene)
function MainScene:ctor()
    MainScene.super.ctor(self);
end		


function MainScene:onEnter()
    MainScene.super.onEnter(self);
	mgrs.log:printFuncCall();
end

function MainScene:onExit()
    mgrs.log:printFuncCall();
    MainScene.super.onExit(self);
end

function MainScene:onEnterTransitionFinish()
    mgrs.log:printFuncCall();
	MainScene.super.onEnterTransitionFinish(self);
    self:gameStart();
end

function MainScene:gameStart()
    self:setBackOrForeGroundEvent();
	self:openWnd();
end

function MainScene:setBackOrForeGroundEvent()
    local eventDispatcher = cc.Director:getInstance():getEventDispatcher()
    local customListenerBg = cc.EventListenerCustom:create(enums.Event.AppEnterBackgroundEvent,
                                handler(self,self.onEnterBackground))
    eventDispatcher:addEventListenerWithFixedPriority(customListenerBg, 1)
    local customListenerFg = cc.EventListenerCustom:create(enums.Event.AppEnterForegroundEvent,
                                handler(self,self.onEnterForeground))
    eventDispatcher:addEventListenerWithFixedPriority(customListenerFg, 1)
end

function MainScene:openWnd()
    mgrs.wnd:openWnd(enums.Wnd.Login,{aa=1});

    --mgrs.wnd:openWnd(enums.Wnd.Loading);
--    mgrs.wnd:openWnd(enums.Wnd.Func);
--	mgrs.wnd:openWnd(enums.Wnd.DownLoad);
--    mgrs.wnd:openWnd(enums.Wnd.Test);
    
end



function MainScene:onEnterBackground()
    mgrs.log:printFuncCall();
end

function MainScene:onEnterForeground()
    mgrs.log:printFuncCall();
end

return MainScene
